package com.ruoyi.project.king.softequip.controller;

import java.util.List;

import com.ruoyi.project.king.softequip.domain.TSoftequip;
import com.ruoyi.project.king.softequip.service.ITSoftequipService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 软装详情Controller
 * 
 * @author ruoyi
 * @date 2020-05-21
 */
@Controller
@RequestMapping("/system/softequip")
public class TSoftequipController extends BaseController
{
    private String prefix = "cms/softequip";

    @Autowired
    private ITSoftequipService tSoftequipService;

    @RequiresPermissions("system:softequip:view")
    @GetMapping()
    public String softequip()
    {
        return prefix + "/softequip";
    }

    /**
     * 查询软装详情列表
     */
    @RequiresPermissions("system:softequip:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSoftequip tSoftequip)
    {
        startPage();
        List<TSoftequip> list = tSoftequipService.selectTSoftequipList(tSoftequip);
        return getDataTable(list);
    }

    /**
     * 导出软装详情列表
     */
    @RequiresPermissions("system:softequip:export")
    @Log(title = "软装详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSoftequip tSoftequip)
    {
        List<TSoftequip> list = tSoftequipService.selectTSoftequipList(tSoftequip);
        ExcelUtil<TSoftequip> util = new ExcelUtil<TSoftequip>(TSoftequip.class);
        return util.exportExcel(list, "softequip");
    }

    /**
     * 新增软装详情
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存软装详情
     */
    @RequiresPermissions("system:softequip:add")
    @Log(title = "软装详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSoftequip tSoftequip)
    {
        return toAjax(tSoftequipService.insertTSoftequip(tSoftequip));
    }

    /**
     * 修改软装详情
     */
    @GetMapping("/edit/{tid}")
    public String edit(@PathVariable("tid") Long tid, ModelMap mmap)
    {
        TSoftequip tSoftequip = tSoftequipService.selectTSoftequipById(tid);
        mmap.put("tSoftequip", tSoftequip);
        return prefix + "/edit";
    }

    /**
     * 修改保存软装详情
     */
    @RequiresPermissions("system:softequip:edit")
    @Log(title = "软装详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSoftequip tSoftequip)
    {
        return toAjax(tSoftequipService.updateTSoftequip(tSoftequip));
    }

    /**
     * 删除软装详情
     */
    @RequiresPermissions("system:softequip:remove")
    @Log(title = "软装详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSoftequipService.deleteTSoftequipByIds(ids));
    }
}
